package com.xnfh.home.ui.activity

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.xnfh.framework.base.BaseActivity
import com.xnfh.framework.bean.ProductIntroduceItem
import com.xnfh.home.R
import com.xnfh.home.adapter.ProductImageAdapter
import com.xnfh.home.databinding.ActivityProductDetailBinding
import com.youth.banner.indicator.CircleIndicator

/**
 * @Description:
 * @Author: ziheng
 * @CreateDate: 2024/1/8 18:10
 * @UpdateUser: ziheng
 * @UpdateDate: 2024/1/8 18:10
 * @UpdateRemark: 更新说明
 */
class ProductDetailActivity: BaseActivity<ActivityProductDetailBinding>() {
    companion object {
        fun start(context: Context, bundle: Bundle? = null) {
            val intent = Intent(context, ProductDetailActivity::class.java)
            if (bundle != null) {
                intent.putExtra("bundle", bundle)
            }
            context.startActivity(intent)
        }
    }
    override fun getLayoutID(): Int = R.layout.activity_product_detail

    override fun init() {
        setHeaderTitle(getString(R.string.str_detail))
        val bundleExtra = intent.getBundleExtra("bundle")
        val productDetail = bundleExtra?.getSerializable("ProductDetail") as ProductIntroduceItem

        mBind.productDetailBanner.addBannerLifecycleObserver(this)
            .setAdapter(ProductImageAdapter(productDetail.tableImgList)).indicator = CircleIndicator(this)

        //类型
        mBind.itemProductDetailType.text = productDetail.productTypeName
        //名称
        mBind.itemProductDetailTypeDetail.text = productDetail.productName
        //适用作物
        mBind.itemProductDetailZuowu.text = productDetail.productCrop
        //介绍
        mBind.itemProductDetailConnect.text = productDetail.productRemark
        //配比
        mBind.itemProductDetailPeibi.text = productDetail.productMatch
    }

    override fun observe() {
    }
}